const {
  Http
} = require("./http")

//登录
const Login = {
  // login(){
  //   // Http('/login?grant_type=mini_app',"POST")
  //   console.log("111")
  // }
}

//分类
const Classfiy = {
  getclasslist(callback) {
    Http('/category/categoryInfo', {}, "GET", callback)
  },
  //分类列表
  categoryList(id, callback) {
    Http('/prod/pageProd', id, "GET", callback)
  }
}

//收搜
const Serach = {
  searchList(prodName, callback) {
    Http('/search/searchProdPage', prodName, "GET", callback)
  }
}

//详情页
const Detail = {
  getDetailList(data, callback) {
    Http(`/prod/prodInfo`, data, "GET", callback)
  }
}

//收藏
const Like = {
  addLike(data, callback) {
    Http(``)
  }
}

//购物车接口
const Car = {
  getCarList(data = {}, callback) {
    Http(`/p/shopCart/info`, data, "POST", callback)
  },

  //添加购物车
  addCar(param, callback) {
    Http(`/p/shopCart/changeItem`, param, "POST", callback)
  },
  setCar(param, callback) {
    Http(`/p/shopCart/changeItem`, param, "POST", callback)
  },
}


//获取省市区信息
const Address = {
  getAddressList(pid, callback) {
    Http(`/p/area/listByPid`, pid, "GET", callback)
  },
  //获取所有地址
  getAddList(callback) {
    Http(`/p/address/list`, {}, "GET", callback)
  },
  //新增收货地址
  addAddress(addrParam, callback) {
    Http(`/p/address/addAddr`, addrParam, "POST", callback)
  },
  //获取地址信息接口
  getAddinfo(addrId, callback) {
    // Http(`/p/address/addrInfo/${addrId}`,{},"GET",callback)
    Http(`/p/address/addrInfo/${addrId}`, {}, "GET", callback)
  },
  //删除地址
  delAddress(addrId, callback) {
    Http(`/p/address/deleteAddr/${addrId}`, {}, "DELETE", callback)
  },
  //修改地址
  updateAdd(addrParam, callback) {
    Http(`/p/address/updateAddr`, addrParam, "PUT", callback)
  },
  //默认地址
  defaAdd(addrId, callback) {
    Http(`/p/address/defaultAddr/${addrId}`, {}, "PUT", callback)
  }
}


//收藏
const Collection = {
  addLike(prodId, callback) {
    Http(`/p/user/collection/addOrCancel`, prodId, "POST", callback)
  },
  getLikeInfo(callback){
    Http(`/p/user/collection/prods`, {}, "GET", callback)
  },
  getLikeCount(callback){
    Http(`/p/user/collection/count`, {}, "GET", callback)
  }
}
// const Like={
//   addLike(prodId,callback){
//     Http(`/p/user/collection/addOrCancel`,prodId,"POST",callback)
//   }
// }
//订单
const Order = {
  //获取订单信息
  orderConfirm(data, callback) {
    Http(`/p/order/confirm`, data, "POST", callback)
  },
  //提交订单
  orderSubmit(data = {}, callback) {
    Http(`/p/order/submit`, data, "POST", callback)
  },
  //支付
  orderPay(payParam, callback) {
    Http(`/p/order/pay`, payParam, "POST", callback)
  },
  //我的订单
  // myOrderList(orderNumber,callback){
  //   Http(`/p/myOrder/orderDetail`, {orderNumber}, "GET", callback)
  // }
  myOrderList(status,callback){
    Http(`/p/myOrder/myOrder`, {status}, "GET", callback)
  }


}

exports.Classfiy = Classfiy
exports.Serach = Serach
exports.Login = Login
exports.Detail = Detail
exports.Car = Car
exports.Order = Order
exports.Address = Address
exports.Collection = Collection